package com.sinaapp.zhangziyou.utils;

import com.sinaapp.zhangziyou.pojo.EmailValEntity;

public class CodeGenerator { 
    public CodeGenerator() { 
    } 
    /** 
     * 生成一个验证code
     * 生成code算法:用MD5方法生成字符串摘要,MD5(userId+$+userName+:+email+!+timeout)
     * @return String code 
     */ 
    public static String getCode(EmailValEntity emailValEntity){ 
		//生成code算法
		//用MD5方法生成字符串摘要
		//MD5(userId+$+userName+:+email+!+timeout)
    	String code = new StringBuffer(emailValEntity.getUserId())
					.append("$").append(emailValEntity.getUserName())
					.append(":").append(emailValEntity.getEmail())
					.append("!").append(DateUtil.getDateTimeStr(emailValEntity.getTimeOut())).toString();
        return DEncryptionUtils.saltMD5Encoder(code);
    } 
}